package com.example.controller;

import com.example.domain.Class;
import com.example.service.ClassService;
import com.example.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/class")
public class ClassController {
    @Autowired
    private ClassService classService;

    /**
     * 获取所有班级信息
     * @return 班级列表
     */
    @GetMapping("/list")
    public Object getAllClasses() {
        try {
            List<Class> classes = classService.getAllClasses();
            return AjaxResult.success(classes);
        } catch (Exception e) {
            return AjaxResult.fail("获取班级列表失败：" + e.getMessage());
        }
    }
} 